<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表格查询</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>


<div class="demoTable" style="margin-left: 15px;">
    <form class="layui-form " action="" >
    <div class="layui-form-item">
        <label>用户ID</label>
        <div class="layui-inline">
            <input class="layui-input" name="userid" id="userid" autocomplete="off">
        </div>
        <label>全款订单单号</label>
        <div class="layui-inline">
            <input class="layui-input" name="ordernum" id="ordernum" autocomplete="off">
        </div>




        <label>定金单号</label>
        <div class="layui-inline">
            <input class="layui-input" name="dingjinNum" id="dingjinNum" autocomplete="off">
        </div>
        <label>尾款单号</label>
        <div class="layui-inline">
            <input class="layui-input" name="weikuanNum" id="weikuanNum" autocomplete="off">
        </div>
        <label>下单时间</label>
        <div class="layui-inline">
            <input class="layui-input" name="ordertimeStatTime" id="ordertimeStatTime" autocomplete="off">
        </div>
        -------------
        <div class="layui-inline">
            <input class="layui-input" name="ordertimeEndTime" id="ordertimeEndTime" autocomplete="off">
        </div>

        <label>姓名</label>
        <div class="layui-inline">
            <input class="layui-input" name="username" id="username" autocomplete="off">
        </div>
        <label>手机号</label>
        <div class="layui-inline">
            <input class="layui-input" name="phone" id="phone" autocomplete="off">
        </div>

        <label>订单状态 </label>
        <div class="layui-inline">
            <select id="status" lay-filter="status">
                <option value="">请选择....</option>
                <option value="0">待确认</option>
                <option value="1">已确认待付款</option>
                <option value="2">进行中</option>
                <option value="3">已结束</option>
            </select>
        </div>

        <label>支付状态  </label>
        <div class="layui-inline">
            <select id="payStatus" lay-filter="status">
                <option value="">请选择....</option>
                <option value="0">未支付</option>
                <option value="1">仅支付定金</option>
                <option value="2">支付完毕(全款) </option>
            </select>
        </div>
        <button type="button" class="layui-btn" data-type="reload">
            <i class="layui-icon layui-icon-search">搜索</i>
        </button>
    </div>
    </form>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="toolbarDemo">


    <form class="layui-form " action="">
        <div class="layui-form-item" style="margin-left: 15px;">
            <div class="layui-btn-group"  >
           <#--     <button type="button" class="layui-btn" lay-event="add">增加</button>-->
                <button type="button" class="layui-btn" lay-event="edit">编辑</button>
                <button type="button" class="layui-btn" lay-event="show">查看</button>
                <button type="button" class="layui-btn" lay-event="del">删除</button>
                <button type="button" class="layui-btn" lay-event="examine">审核</button>
            </div>
        </div>

    </form>
</script>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script src="${base}/static/win10/js/zhang.js?t=1"></script>
<script>
    layui.use(['table','util','laydate'], function () {
        var table = layui.table;      var util = layui.util;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#ordertimeStatTime' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#ordertimeEndTime' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });

        table.render({
            skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , elem: '#test'
            , url: base + '/bus/orderbus/findOrderbusByPage'
            , toolbar: '#toolbarDemo'
            , cols: [[
                {type: 'radio'},
                  {field: 'id', title: '编号' },
                  {field: 'dingjinNum', title: '定金单号'},
                  {field: 'weikuanNum', title: '尾款单号'},
                  {field: 'ordertime', title: '下单时间', templet: function(val){
                          if(val.ordertime==null){
                              return "无";
                          }
                          return changeDateFormat(val.ordertime)
                      }},
                  {field: 'username', title: '姓名'},
                  {field: 'phone', title: '手机号'},
                  {field: 'status', title: '订单状态', templet: function(val){
                            if(val.status==0){
                                return  "待确认"
                            }
                            if(val.status==1){
                                return  "已确认待付款"
                            }
                            if(val.status==2){
                                return  "进行中"
                            }
                            if(val.status==3){
                                return  "已结束"
                            }
                            return "无法获取订单状态";
                      }},
                  {field: 'jine', title: '全款金额'},
                  {field: 'payStatus', title: '支付状态', templet: function(val){
                          if(val.payStatus==0){
                              return  "未支付"
                          }
                          if(val.payStatus==1){
                              return  "仅支付定金"
                          }
                          if(val.payStatus==2){
                              return  "支付完毕(全款)"
                          }
                          return "无法获取支付状态";
                      }}
            ]]
            , page: true
            , id: 'testReload'
        });
        //搜索
        var $ = layui.$, active = {
            reload: function(){
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        ordertimeStatTime:$("#ordertimeStatTime").val(),
                        ordertimeEndTime:$("#ordertimeEndTime").val(),
                                    ordernum:$("#ordernum").val(),
                                    dingjinNum:$("#dingjinNum").val(),
                                    weikuanNum:$("#weikuanNum").val(),
                                    ordertime:$("#ordertime").val(),
                                    username:$("#username").val(),
                                    phone:$("#phone").val(),
                                    choosetime:$("#choosetime").val(),
                                    stationup:$("#stationup").val(),
                                    stationdown:$("#stationdown").val(),
                                    peoplenumber:$("#peoplenumber").val(),
                                    status:$("#status").val(),
                                    userid:$("#userid").val(),
                                    beizhu:$("#beizhu").val(),
                                    jine:$("#jine").val(),
                                    weikuan:$("#weikuan").val(),
                                    dingjin:$("#dingjin").val(),
                                    yongtu:$("#yongtu").val(),
                                    payMoney:$("#payMoney").val(),
                                    payStatus:$("#payStatus").val(),
                                    paytime1:$("#paytime1").val(),
                                    paytime2:$("#paytime2").val(),
                                    paytime3:$("#paytime3").val(),
                                    payType:$("#payType").val()
                    }
                }, 'data');
            }
        };
        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });





        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
            var data = checkStatus.data;  //获取选中行数据
            switch (obj.event) {
                case 'examine':
                    if(data[0].status==0){
                        //请继续补充以下逻辑
                        window.location.href=base+"/bus/orderbus/examineHtml?id=" + data[0].id
                    }else{
                        layer.alert("当前订单不允许审核")
                    }

                    break;
                case 'add':
                    //请继续补充以下逻辑
                    window.location.href=base+"/bus/orderbus/addOrderbusHtml"
                    break;
                case 'edit':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    //请继续补充以下逻辑
                    window.location.href=base+"/bus/orderbus/editOrderbusHtml?id=" + data[0].id
                    break;
                case 'show':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    //请继续补充以下逻辑
                    window.location.href=base+"/bus/orderbus/showOrderbusHtml?id=" + data[0].id
                    break;
                case 'del':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    layer.confirm('真的要删除吗?',function(index){
                        $.ajax({
                            type:"POST",
                            url:base+'/bus/orderbus/delOrderbus',
                            data:{"id":data[0].id},
                            success:function(data){
                                if(data.code===200){
                                    layer.msg(data.message)
                                    setTimeout(function () {
                                        window.location.reload();
                                    }, 500)
                                }else{
                                    layer.msg(data.message)
                                }
                            }
                        });
                    });
                    break;
            };
        });
    })
</script>
</body>
</html>